< previous page page_871 next page >

Page 871
Type.gifListing A.2. Adding code to the Form_Load event.
Private Sub Form_Load()
    '
    Me.Data1.Refresh
    DoEvents
    '
    ' set the captions
    Me.Caption = Trim(strGlobalSelect)
    Me.Data1.Caption = Trim(strGlobalSelect)
    Me.DBGrid1.Caption = Trim(strGlobalSelect)
    '
End Sub
The code in Listing A.2 first refreshes the data control and yields to let Windows catch up with any pending messages, then sets the Caption properties.
The Form_Unload event contains a single line of code. This line clears up the main (SQLVBMain) form's menu display.
Private Sub Form_Unload(Cancel As Integer)
   '
   SQLVBMain.mnuWindows.Visible = False
   '
End Sub
Next, add code to the Form_Activate event. This updates the MDI form menus and rebinds the data from the data control to the grid display.
Private Sub Form_Activate()
    '
    SQLVBMain.mnuWindows.Visible = True
    DBGrid1.ReBind
    '
End Sub
The last code piece needed for the SQLVBChild form is the code behind the Form_Resize event (see Listing A.3). This code automatically resizes the DBGrid and Data controls whenever the user resizes the form. Note the If test that occurs at the start of the routine. Whenever a form is minimized, the Form_Resize event occurs. Attempts to resize a minimized form result in Visual Basic errors, so check to make sure the form is not minimized before you continue with the routine.

 
< previous page page_871 next page >

If you like this book, buy it!